package com.xiaoxu.intranetweb.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
// request.getHeader("Local-Transmission");如果是本地发过来的请求会有Local-Transmission，检查请求头是否需要解码
public class DecodeLocalHttpRequest {
//    如果是GBK
    public static String decodeGb2312IfNecessary(String value) throws UnsupportedEncodingException {
        Charset charset = Charset.forName("GBK");
        try {
            return URLDecoder.decode(value, String.valueOf(charset));
        } catch (Exception e) {
            e.printStackTrace();
            return value;
        }
    }
}
